import Vue from 'vue'
import VueRouter from 'vue-router'

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {
		path: "/",
		name: "root",
		meta: { hidden: true },
		redirect: '/home'
	},
	// {
  //   path: '/login',
  //   name: "登录",
  //   meta: { hidden: true },
  //   component: ()=>import('@/pages/login/index.vue'),
  // },
  {
		path: "/main",
		meta: { hidden: false, leftNav:true},
		component: () => import('@/pages/main/index.vue'),
		children: [
			{
				path: "/home",
				name: "首页",
				meta: { nowIndex: 0, isNav: true, icon: '' ,requireAuth:true},
				component:  () => import('@/pages/home/index.vue'),
			},
      {
				path: "/orderManagement",
				name: "订单管理",
				meta: { nowIndex: 1, isNav: true, isChild: true , icon: '',requireAuth:true },
				component: () => import('@/pages/OrderManagement/index.vue'),
        children:[
          {
            path: "/orderManagement/orderList",
            name: "订单列表",
            meta: { nowIndex: 1, index:0, isNav: true, icon: '',requireAuth:true },
            component: ()=>import('@/pages/OrderManagement/orderList/index.vue'),
          },
          {
            path: "/orderManagement/evaluate",
            name: "评价列表",
            meta: { nowIndex: 1, index:1, isNav: true, icon: '', isChild: true ,requireAuth:true},
            component: () => import ('@/pages/OrderManagement/evaluate/index.vue'),
          },
        ]
			},
			{
				path: "/shopList",
				name: "商品管理",
				meta: { nowIndex: 2, isNav: true, icon: '',requireAuth:true },
				component: ()=>import('@/pages/shopList/index.vue')
			},
			{
				path: "/custom",
				name: "客户列表",
				meta: { nowIndex: 3, isNav: true, icon: '',requireAuth:true },
				component: ()=>import('@/pages/custom/index.vue')
			},
			{
				path: "/shopStore",
				name: "店铺设置",
				meta: { nowIndex: 4, isNav: true, icon: '',requireAuth:true },
				component: ()=>import('@/pages/shopStore/index.vue')
			},
			{
				path: "/roleManagement",
				name: "角色管理",
				meta: { nowIndex: 5, isNav: true, icon: '',requireAuth:true },
				component: ()=>import('@/pages/roleManagement/index.vue')
			}
		]
	}
]

const router = new VueRouter({
  routes
})

export default router
